Go to Home Page
Questions?
Call 1-800-572-5517
 
  Go to Home Page  
  See all products
  See price schedules
  See manuals, tutorials, articles
  Download a free 30-day trial
  See user testimonials
  About Pacific Systems Group
 
 
SMF Tools
  See SMF Record Layouts
  See Sample SMF Reports
  Learn How to Export SMF Data
  Download Free SMF Reporting Software (30 days)
 
One of the greatest SMF record parsing programming languages I've ever seen. Chief, Large Systems Services Branch, NIH
  Choose Spectrum Writer to add 4GL to your product
  Report Writer Speedup Tips Article
Spectrum SMF Writer - the 4GL SMF Report Writer.

Add customized reports and PC export files to your product!

Table of Contents

NOTE: you can find this and other lessons in a
more complete and viewable format (including all Figures) in our Tutorial PDF.

Lesson 2. How to Include Only Certain Records from the SMF File

  1. This lesson teaches you how to select only certain records from the SMF file for inclusion in your report. The control statement discussed is:
  2. the INCLUDEIF statement
How to Use the INCLUDEIF Statement
  1. Let us revise something that we said in the previous lesson. The truth is that you can make a Spectrum SMF Writer report with just two control statements (the INPUT and COLUMNS statements.) When no INCLUDEIF statement is given, Spectrum SMF Writer includes every record from the input file in your report.
  2. But since the SMF file contains dozens of different record types (each containing different kinds of data) it is not very useful to include all records in a single report. So it is safe to say that most of your reports will use an INCLUDEIF statement to limit the records used in a given report.
  3. The INCLUDEIF statement tells Spectrum SMF Writer to "include" an SMF record in the report only "if" one or more conditions are met. In the example in Figure, we included records in the report if the record type field was equal to 14. So that report includes every type 14 record from the input file.
  4. Most of your reports will consist of data from only one type of SMF record. But often you will want to limit the records that appear in your report even further. You do this by specifying more than one condition (or test) in the INCLUDEIF statement. Consider these statements:

INPUT: SMF30 /* COPY SMF30 RECORD DEFINITIONS */
INCLUDEIF: SMF30RTY = 30 AND SMF30STY = 5 /* SELECT SMF TYPE 30, SUBTYPE 5 RECS */

  1. The above statements select just the type 30 with a subtype of 5 for the report. Subtype 5 records are written at job termination time, so those are a good source of job accounting information. We will use the above statements in some later examples.
  2. Sometimes you may just want to look at the SMF data for one particular job, or maybe for any jobs that access a certain group of datasets. You will use the INCLUDEIF statement in such cases:

INCLUDEIF: SMF14RTY = 14 AND (SMF30JBN = 'ACCT1000' OR SMF30_JFCBDSN : 'PROD.ACCT')

  1. The above statement will include any type 14 record whose jobname is 'ACCT1000' or where the dataset accessed contains the characters 'PROD.ACCT' somewhere within its DSNAME.
  2. The colon comparison operator (:) is a special feature of Spectrum SMF Writer. It allows you to scan a field to see if a given text appears anywhere within it. This is a very handy feature for writing condition expressions with Spectrum SMF Writer.
  3. The INCLUDEIF statement may appear anywhere after the INPUT statement. Only one INCLUDEIF statement is allowed per report, but it may contain as many conditions as you like.
  4. By the way, the INCLUDEIF statement may refer to any of the fields defined for the input file (as well as any COMPUTE field). You are not limited to just those fields that are listed in the COLUMNS statement, for example.
Conditional Expressions
  1. The contents of the INCLUDEIF statement is simply a conditional expression. The complete rules for conditional expressions are discussed in "Conditional Expressions" (page 459) in the Reference Manual. It is generally the same as for such languages as BASIC, COBOL, etc.
  2. Here is a summary of some of the main syntax rules for conditional expressions:
Comparators and Logical Connectors
  1. The following conditional operators are supported: <, <=, =, >=, >, and ¬= or <>. Spectrum SMF Writer also has these 2 special operators : (contains) and ¬: (does not contain) that scan a field for the specified text.
  2. Your expression can contain any number of conditions, separated with the words AND and OR , optionally preceded by NOT , nested as needed within parentheses. You can also use the symbols & , | and ¬.
Character Literals
  1. Character literals must appear within single or double quote marks. To embed the same quote character within the literal, double it. The following are all valid examples of a character literal:
  2. 'JONES'
  3. "JONES"
  4. 'JONE''S'
  5. "JONE'S"
  6. Character literals can also be specified in hexadecimal format by prefixing the literal with an X , like this: X'FFFF'
Numeric Literals
  1. Numeric literals should not be contained within quotes. No punctuation is allowed other than a minus sign and a decimal point.
Date Literals
  1. Date literals should be in either MM/DD/YY or MM/DD/YYYY format (leading zeros not required).
  2. If you use YY in your date literals, it is understood to represent a year between 1951 and 2050. However, you can specify your own cutover year by specifying the CENTURY option.
  3. you may want to specify the following option near the beginning of your control statements:

OPTION: DDMMYYLIT

This option indicates that all date literals in the control statements will be in DD/MM/YY or DD/MM/YYYY format.

Comparing Dates
  1. One very powerful feature of Spectrum SMF Writer often takes some getting used to by programmers. If they have used other report writers, programmers are used to matching the format of their date literal with the format of the raw data in the record being tested. For example, if a record contains packed Julian dates, programmers usually have to look up the desired date in Julian and then write their comparison literal in the same packed Julian date format.
  2. With Spectrum SMF Writer, this is not necessary. The program automatically handles all required date conversions for you. So, whether a raw field is stored in the record as a packed Julian date, a character YYYYMMDD or MMDDYY date, an 8-byte STCK date, or a binary day in century (to name a few of the formats), you always write your comparison dates in MM/DD/[YY]YY format.
  3. As an example, even though the SMF14DTE field is stored in the SMF record in packed P'CYYDDD' format, you just test it like this:

INCLUDEIF: SMF14RTY= 14 AND SMF14DTE >= 6/30/2010 AND <= 7/13/2010

  1. The only exception would be if a field has accidentally been defined (in the copy library) as a plain character or numeric field (rather than a true date field). In that case, you do need to compare it with a character or numeric literal of the same format. In that case, you may also want to change the field's definition (in the copy library). Just locate the correct FIELD statement and add a TYPE parm that specifies one of the dozens of Date Data Types listed in Appendix A of the Reference Manual. Then you will be able to test that field using date literals. (And the field will also be formatted correctly as a date in the report output.)
Time Literals
  1. Time literals should be in 24-hour HH:MM or HH:MM:SS[.DDD...] format.
Comparing Times
  1. Once again, you do not need to be concerned with exactly how a time or interval field is stored in the SMF record. As long as the field is defined as a true time field, Spectrum SMF Writer automatically handles all required conversions for you. So, whether a field is stored in the record as packed seconds since midnight, character HHMM , an 8-byte STCK time, or binary microseconds since midnight (to name a few examples), you always write your comparison times in HH:MM[:SS] format.
  2. For example, even though the SMF14TME field is stored in the SMF record as hundredths of a second since midnight, you will test it like this:

INCLUDEIF: SMF14RTY= 14 AND SMF14DTE = 9/1/2010 AND SMF14TME >= 13:00 AND < 14:00

  1. Again, if a time field has accidentally been defined as a regular character or numeric fields then you will need to compare it with a character or numeric literal of the same format. Or you can locate the correct FIELD statement in the copy library and add a TYPE parm that specifies one of the dozens of Time Data Types listed in Appendix A of the Reference Manual. You may also need to add a DEC(n) parm to the FIELD statement, if the time field contains decimal parts of a second.
Comparing a List of Values
  1. If you want to compare a field to a list of values, you can use this shorthand format:

INCLUDEIF: SMF14JBN = 'ACCT1000' OR 'ACCT1100' OR 'ACCT1200'

  1. Or to exclude a list of values, use this format:

INCLUDEIF: SMF14JBN <> 'ACCT1000' AND 'ACCT1100' AND 'ACCT1200'

Syntax for Continuation Lines
  1. Often the INCLUDEIF statement will be too long to fit on one control statement. (Spectrum SMF Writer uses columns 1 through 72 of each statement. Anything in columns 73-80 is ignored.) You may continue your INCLUDEIF statement onto as many lines as needed. Just be sure to begin each continuation line with a blank in column 1.
  2. If you need to break a literal onto multiple lines, continue up to column 72 in one line and resume it in column 2 of the next line.
Summary
  1. Here is a summary of what we learned in this lesson:
  2. an INCLUDEIF statement is used to tell Spectrum SMF Writer which records from the input file to include in the report
  3. an INCLUDEIF statement consists of a conditional expression
  4. you can compare any (true) date field in an SMF record with a MM/DD/YY or MM/DD/YYYY literal
  5. you can compare any (true) time field in an SMF record with a HH:MM or HH:MM:SS literal
  6. The next lesson will teach you how to turn an SMF report into an export file for PC programs.
To Learn More
  1. You can also learn:
  2. how to specify conditions based on bit fields
  3. how to use the STOPWHEN parm on the INPUT statement to limit the records read from the SMF file
  4. the complete syntax for the INCLUDEIF statement, in
NEXT LESSON: How to Export SMF Data to PC Programs

Spectrum SMF Writer - the 4GL SMF Report Writer.

Copyright 2024.
Pacific Systems Group.
All rights reserved.
Home | Products | Prices | Documentation | 30-Day Trials | Customer Reviews | Company | FAQ | Sample Reports | SMF Records
Send Your Comments or Questions